/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019.
 * Description: This file contains driver APIs to the rtos_reset_notifier.
 * Author: Jiangfeng Xiao
 * Create: 2019-08-13
 */

#include <linux/notifier.h>
#include <linux/types.h>

static ATOMIC_NOTIFIER_HEAD(reset_notifier_chain);
int register_reset_notifier(struct notifier_block *nb)
{
	if (nb == NULL) {
		printk(KERN_ERR "register reset notifier failed\n");
		return -ENOENT;
	}

	return atomic_notifier_chain_register(&reset_notifier_chain, nb);
}
EXPORT_SYMBOL_GPL(register_reset_notifier);

int unregister_reset_notifier(struct notifier_block *nb)
{
	if (nb == NULL) {
		printk(KERN_ERR "unregister reset notifier failed\n");
		return -ENOENT;
	}

	return atomic_notifier_chain_unregister(&reset_notifier_chain, nb);
}
EXPORT_SYMBOL_GPL(unregister_reset_notifier);

/*
 *      call_reset_notifiers - Execute arch reset handler call chain
 *
 */
int call_reset_notifiers(void)
{
	return atomic_notifier_call_chain(&reset_notifier_chain, 0, NULL);
}
EXPORT_SYMBOL_GPL(call_reset_notifiers);

